
package persistencia.utils;

import javax.swing.JOptionPane;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

/**
 * Gerencia a fabrica de sessões
 * @author Maycon
 */
public class hibernateSessionFactory_bd_resti {

    private static SessionFactory fabricaSessoes;
    static{
        try{
            fabricaSessoes = new Configuration().configure("hibernate.cfg.xml").buildSessionFactory();

        }
        catch(Exception er){
            JOptionPane.showMessageDialog(null, "Erro ao criar a SessionFactory.\n " +er);
            er.printStackTrace();
            fabricaSessoes = null;
        }
    }

    public static Session getSession(){
        return fabricaSessoes.openSession();
    }

}
